//
//  RegisterViewController.m
//  EastMarket
//
//  Created by 李鹏程 on 16/10/19.
//  Copyright © 2016年 guoguo. All rights reserved.
//

#import "RegisterViewController.h"

@interface RegisterViewController ()
{
    UIView *bgView;
    UITextField *phone;
    UITextField *code;
    UITextField *invitationCode;
    UITextField *passward;
    UITextField *passwardConfirm;
    UINavigationBar *customNavigationBar;
    UIButton *yzButton;
    QCheckBox *checkagreeBox;
}

@property(nonatomic, copy) NSString *oUserPhoneNum;
@property(assign, nonatomic) NSInteger timeCount;
@property(strong, nonatomic) NSTimer *timer;
//验证码
@property(copy, nonatomic) NSString *smsId;
@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"用户注册";
    self.view.backgroundColor = EastMarket_backgroundColor;
    [self createTextFields];
}

-(void)createTextFields
{
    CGFloat spacing = 8.0f;
    CGFloat border = 1.0f;
    
    // 背景ScrollView
    UIScrollView *applicationSV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    applicationSV.showsVerticalScrollIndicator = YES;
    applicationSV.showsVerticalScrollIndicator = NO;
    applicationSV.backgroundColor = [UIColor clearColor];
    applicationSV.delegate = self;
    applicationSV.scrollEnabled = YES;
    [self.view addSubview:applicationSV];
    
    applicationSV.userInteractionEnabled = true;
    UITapGestureRecognizer *tapViewHead = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyBoardDissing:)];
    [applicationSV addGestureRecognizer:tapViewHead];

    
    bgView = [[UIView alloc]initWithFrame:CGRectMake(0, spacing * 2, SCREEN_WIDTH, SCREEN_HEIGHT / 3)];
    bgView.layer.cornerRadius = 3.0;
    bgView.backgroundColor = [UIColor whiteColor];
    [applicationSV addSubview:bgView];
    
    // 手机号
    UILabel *phonelabel = [[UILabel alloc]initWithFrame:CGRectMake(spacing * 2, 0, (bgView.frame.size.width - 6 * spacing) / 4, bgView.frame.size.height / 4)];
    phonelabel.text = @"手机号";
    phonelabel.textColor = [UIColor blackColor];
    phonelabel.textAlignment = NSTextAlignmentLeft;
    phonelabel.font = [UIFont systemFontOfSize:14];
    
    phone = [self createTextFielfFrame:CGRectMake(phonelabel.frame.origin.x + phonelabel.frame.size.width + spacing, phonelabel.frame.origin.y, (bgView.frame.size.width - 6 * spacing) / 2, phonelabel.frame.size.height) font:[UIFont systemFontOfSize:14] placeholder:@"您的手机号"];
    phone.clearButtonMode = UITextFieldViewModeWhileEditing;
    phone.keyboardType = UIKeyboardTypeNumberPad;
    
    // 获取验证码
    yzButton = [[UIButton alloc]initWithFrame:CGRectMake(phone.frame.origin.x + 1 + phone.frame.size.width, phone.frame.origin.y, (bgView.frame.size.width - 6 * spacing) / 4 + spacing - 1, phone.frame.size.height)];
    [yzButton setTitle:@"发送验证码" forState:UIControlStateNormal];
    [yzButton setTitleColor:EastMarket_MainToneColor forState:UIControlStateNormal];
    
    if (IPHONE4) {
        
        [yzButton.titleLabel setFont:[UIFont systemFontOfSize:12]];
    } else {
        
        [yzButton.titleLabel setFont:[UIFont systemFontOfSize:13]];
    }
    [yzButton addTarget:self action:@selector(getValidCode:) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:yzButton];

    
    UIImageView *line1=[self createImageViewFrame:CGRectMake(phonelabel.frame.origin.x, phonelabel.frame.origin.y + phonelabel.frame.size.height - border, bgView.frame.size.width - 4 * spacing, border) imageName:nil color:[UIColor colorWithRed:180/255.0f green:180/255.0f blue:180/255.0f alpha:.3]];
    
    // 验证码
    UILabel *codelabel = [[UILabel alloc]initWithFrame:CGRectMake(phonelabel.frame.origin.x, phonelabel.frame.origin.y + phonelabel.frame.size.height, (bgView.frame.size.width - 5 * spacing) / 4, phonelabel.frame.size.height)];
    codelabel.text = @"验证码";
    codelabel.textColor = [UIColor blackColor];
    codelabel.textAlignment = NSTextAlignmentLeft;
    codelabel.font = [UIFont systemFontOfSize:14];
    
    code = [self createTextFielfFrame:CGRectMake(phone.frame.origin.x, codelabel.frame.origin.y, bgView.frame.size.width - 5 * spacing - phonelabel.frame.size.width, phone.frame.size.height) font:[UIFont systemFontOfSize:14]  placeholder:@"您手机收到的验证码" ];
    code.clearButtonMode = UITextFieldViewModeWhileEditing;
    code.keyboardType = UIKeyboardTypeNumberPad;
    
    UIImageView *line2=[self createImageViewFrame:CGRectMake(codelabel.frame.origin.x, codelabel.frame.origin.y + codelabel.frame.size.height - border, line1.frame.size.width, border) imageName:nil color:[UIColor colorWithRed:180/255.0f green:180/255.0f blue:180/255.0f alpha:.3]];
    
    // 密码：
    UILabel *passwordlabel = [[UILabel alloc] initWithFrame:CGRectMake(phonelabel.frame.origin.x, codelabel.frame.origin.y + codelabel.frame.size.height, codelabel.frame.size.width, phonelabel.frame.size.height)];
    passwordlabel.text = @"密码";
    passwordlabel.textColor = [UIColor blackColor];
    passwordlabel.textAlignment = NSTextAlignmentLeft;
    passwordlabel.font = [UIFont systemFontOfSize:14];
    
    passward = [self createTextFielfFrame:CGRectMake(phone.frame.origin.x, passwordlabel.frame.origin.y, phone.frame.size.width, phone.frame.size.height) font:[UIFont systemFontOfSize:14] placeholder:@"请输入您的密码"];
    passward.clearButtonMode = UITextFieldViewModeWhileEditing;
    passward.secureTextEntry = YES;
    passward.delegate = self;
    
    UIImageView *line4=[self createImageViewFrame:CGRectMake(line1.frame.origin.x, passwordlabel.frame.origin.y + passwordlabel.frame.size.height - border, line1.frame.size.width, border) imageName:nil color:[UIColor colorWithRed:180/255.0f green:180/255.0f blue:180/255.0f alpha:.3]];
    
    // 确认密码
    UILabel *passwordConfirmlabel = [[UILabel alloc] initWithFrame:CGRectMake(phonelabel.frame.origin.x, passwordlabel.frame.origin.y + passwordlabel.frame.size.height, codelabel.frame.size.width, phonelabel.frame.size.height)];
    passwordConfirmlabel.text = @"确认密码";
    passwordConfirmlabel.textColor = [UIColor blackColor];
    passwordConfirmlabel.textAlignment = NSTextAlignmentLeft;
    passwordConfirmlabel.font = [UIFont systemFontOfSize:14];
    
    passwardConfirm = [self createTextFielfFrame:CGRectMake(passward.frame.origin.x, passwordConfirmlabel.frame.origin.y, passward.frame.size.width, passward.frame.size.height) font:[UIFont systemFontOfSize:14] placeholder:@"请重新输入您的密码"];
    passwardConfirm.clearButtonMode = UITextFieldViewModeWhileEditing;
    passwardConfirm.secureTextEntry = YES;
    passwardConfirm.delegate = self;
    
    
    UIView *viewInvitationCode = [[UIView alloc]initWithFrame:CGRectMake(0, bgView.frame.origin.y + bgView.frame.size.height + 2 * spacing, SCREEN_WIDTH, SCREEN_HEIGHT / 12)];
    viewInvitationCode.layer.cornerRadius = 3.0;
    viewInvitationCode.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:viewInvitationCode];

    // 邀请码
    UILabel *invitationCodelabel = [[UILabel alloc] initWithFrame:CGRectMake(phonelabel.frame.origin.x, 0, codelabel.frame.size.width, phonelabel.frame.size.height)];
    invitationCodelabel.text = @"邀请码";
    invitationCodelabel.textColor = [UIColor blackColor];
    invitationCodelabel.textAlignment = NSTextAlignmentLeft;
    invitationCodelabel.font = [UIFont systemFontOfSize:14];
    
    invitationCode = [self createTextFielfFrame:CGRectMake(code.frame.origin.x, invitationCodelabel.frame.origin.y, code.frame.size.width, code.frame.size.height) font:[UIFont systemFontOfSize:14] placeholder:@"请输入您的邀请码"];
    invitationCode.clearButtonMode = UITextFieldViewModeWhileEditing;
    invitationCode.delegate = self;
    
//    UIImageView *line3=[self createImageViewFrame:CGRectMake(line1.frame.origin.x, invitationCodelabel.frame.origin.y + invitationCodelabel.frame.size.height - border, line1.frame.size.width, border) imageName:nil color:[UIColor colorWithRed:180/255.0f green:180/255.0f blue:180/255.0f alpha:.3]];

    
    UIButton *landBtn=[self createButtonFrame:CGRectMake(2 * spacing, viewInvitationCode.frame.size.height + viewInvitationCode.frame.origin.y + 4 * spacing, SCREEN_WIDTH - 4 * spacing, 44) backImageName:nil title:@"注册" titleColor:[UIColor whiteColor]  font:[UIFont systemFontOfSize:17] target:self action:@selector(next:)];
    landBtn.backgroundColor = EastMarket_MainToneColor;
    landBtn.layer.cornerRadius=5.0f;
    
    checkagreeBox = [[QCheckBox alloc] initWithDelegate:self];
    checkagreeBox.frame = CGRectMake(landBtn.frame.origin.x, landBtn.frame.origin.y + landBtn.frame.size.height + spacing, 16, 16);
    checkagreeBox.checked = YES;
    [self.view addSubview:checkagreeBox];
    
    UILabel *lblAgreementTips = [[UILabel alloc] initWithFrame:CGRectMake(checkagreeBox.frame.origin.x + checkagreeBox.frame.size.width + spacing * 2, checkagreeBox.frame.origin.y, (SCREEN_WIDTH - checkagreeBox.frame.origin.x - checkagreeBox.frame.size.width - 4 * spacing) / 3, 16)];
    lblAgreementTips.text = @"我已阅读并同意";
    lblAgreementTips.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:lblAgreementTips];
    
    UILabel *lblAgreement = [[UILabel alloc] initWithFrame:CGRectMake(lblAgreementTips.frame.origin.x + lblAgreementTips.frame.size.width, checkagreeBox.frame.origin.y, (SCREEN_WIDTH - checkagreeBox.frame.origin.x - checkagreeBox.frame.size.width - 4 * spacing) * 2 / 3, 16)];
    lblAgreement.text = @"《咪族购服务条款》";
    lblAgreement.font = [UIFont systemFontOfSize:14];
    lblAgreement.textColor = EastMarket_BlueColor;
    [self.view addSubview:lblAgreement];
    
    lblAgreement.userInteractionEnabled = true;
    UITapGestureRecognizer *taplblAgreement = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(taplblAgreement:)];
    [lblAgreement addGestureRecognizer:taplblAgreement];
    
    [bgView addSubview:phonelabel];
    [bgView addSubview:codelabel];
    [viewInvitationCode addSubview:invitationCodelabel];
    [bgView addSubview:passwordlabel];
    [bgView addSubview:passwordConfirmlabel];
    
    [bgView addSubview:phone];
    [bgView addSubview:code];
    [viewInvitationCode addSubview:invitationCode];
    [bgView addSubview:passward];
    [bgView addSubview:passwardConfirm];
    
    [bgView addSubview:line1];
    [bgView addSubview:line2];
//    [bgView addSubview:line3];
    [bgView addSubview:line4];
    [applicationSV addSubview:landBtn];
    
    applicationSV.contentSize = CGSizeMake(SCREEN_WIDTH, landBtn.frame.origin.y + landBtn.frame.size.height + TopBarHeight);
}
/*
 UITextField *phone;
 UITextField *code;
 UITextField *invitationCode;
 UITextField *passward;
 UITextField *passwardConfirm;

 */
- (void)keyBoardDissing:(UIGestureRecognizer *)tap {

    [phone resignFirstResponder];
    [code resignFirstResponder];
    [invitationCode resignFirstResponder];
    [passward resignFirstResponder];
    [passwardConfirm resignFirstResponder];
    //键盘收回后视图移动回原位的动画
    [UIView animateWithDuration:0.3 animations:^{
        
        float width = self.view.frame.size.width;
        float hight = self.view.frame.size.height;
        
        CGRect rect = CGRectMake(0, 44 + 20, width, hight);
        self.view.frame = rect;
    }];
}

- (void)getValidCode:(UIButton *)sender
{
    if ([GlobalUnit isBlankString:phone.text]) {
        [GlobalUnit showPopHint:@"请输入手机号" targetView:phone showInView:self.view];
        return;
    } else if (![GlobalUnit isMobile:phone.text]) {
        [GlobalUnit showPopHint:@"请输入正确手机号" targetView:phone showInView:self.view];
        return;
    }
    [NSThread detachNewThreadSelector:@selector(callServerSendMobileCheckCode) toTarget:self withObject:nil];
    _oUserPhoneNum =phone.text;
    //__weak MMZCHMViewController *weakSelf = self;
    sender.userInteractionEnabled = NO;
    self.timeCount = 60;
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];
}

- (void)callServerSendMobileCheckCode {
    
    NSDictionary *dic = [AppServiceInterface SendMobileCheckCode:phone.text];
    debugLog(@"dic:%@", dic);
     [self performSelectorOnMainThread:@selector(getResultForSendMobileCode:) withObject:dic waitUntilDone:false];
}

- (void)getResultForSendMobileCode:(NSDictionary *)dic {

    if (dic && [[dic objectForKey:@"success"] integerValue] == 1) {

        NSString *showMsg = @"删除订单成功";
        if ([[dic objectForKey:@"msg"] isKindOfClass:[NSNull class]]) {
            showMsg = [NSString stringWithFormat:@"%@", [dic objectForKey:@"msg"]];
        }
        [GlobalUnit showMessage:[NSString stringWithFormat:@"%@", showMsg]];
    } else if (dic && !([[dic objectForKey:@"success"] integerValue] != 1)) {
    
        NSString *showMsg = @"验证码发送失败";
        if ([[dic objectForKey:@"msg"] isKindOfClass:[NSNull class]]) {
            showMsg = [NSString stringWithFormat:@"%@", [dic objectForKey:@"msg"]];
        }
        [GlobalUnit showMessage:[NSString stringWithFormat:@"%@", showMsg]];
    } else {
    
        [GlobalUnit showAlertHint:@"温馨提示！" message:@"请求服务器失败，请稍后重试"];
    }
}

- (void)reduceTime:(NSTimer *)codeTimer {
    self.timeCount--;
    if (self.timeCount == 0) {
        [yzButton setTitle:@"重新获取" forState:UIControlStateNormal];
        [yzButton setTitleColor:[UIColor colorWithRed:248/255.0f green:144/255.0f blue:34/255.0f alpha:1] forState:UIControlStateNormal];
        UIButton *info = codeTimer.userInfo;
        info.enabled = YES;
        yzButton.userInteractionEnabled = YES;
        [self.timer invalidate];
    } else {
        NSString *str = [NSString stringWithFormat:@"重新获取(%lu)", self.timeCount];
        [yzButton setTitle:str forState:UIControlStateNormal];
        yzButton.userInteractionEnabled = NO;
    }
}

-(UITextField *)createTextFielfFrame:(CGRect)frame font:(UIFont *)font placeholder:(NSString *)placeholder
{
    UITextField *textField=[[UITextField alloc]initWithFrame:frame];
    
    textField.font=font;
    
    textField.textColor=[UIColor grayColor];
    
    textField.borderStyle=UITextBorderStyleNone;
    
    textField.placeholder=placeholder;
    
    return textField;
}

-(UIImageView *)createImageViewFrame:(CGRect)frame imageName:(NSString *)imageName color:(UIColor *)color
{
    UIImageView *imageView=[[UIImageView alloc]initWithFrame:frame];
    
    if (imageName)
    {
        imageView.image=[UIImage imageNamed:imageName];
    }
    if (color)
    {
        imageView.backgroundColor=color;
    }
    
    return imageView;
}

-(UIButton *)createButtonFrame:(CGRect)frame backImageName:(NSString *)imageName title:(NSString *)title titleColor:(UIColor *)color font:(UIFont *)font target:(id)target action:(SEL)action
{
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame=frame;
    if (imageName)
    {
        [btn setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    }
    
    if (font)
    {
        btn.titleLabel.font=font;
    }
    
    if (title)
    {
        [btn setTitle:title forState:UIControlStateNormal];
    }
    if (color)
    {
        [btn setTitleColor:color forState:UIControlStateNormal];
    }
    if (target&&action)
    {
        [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    }
    return btn;
}

#pragma mark --  数据请求
/*
- (void)callServerRegister {
    
    NSDictionary *productsDic = [AppWebServiceInterface Register:phone.text password:passward.text mobileCheckCode:code.text inviteCode:invitationCode.text channel:2];
    [self performSelectorOnMainThread:@selector(updateRegisterUI:) withObject:productsDic waitUntilDone:NO];
    
}
*/
/*
- (void)updateRegisterUI:(NSDictionary *)dic {
    
    debugLog(@"%@", [dic objectForKey:@"success"]);
    if ([[dic objectForKey:@"success"] integerValue] == 1) {
        globalManager.token = [NSString stringWithFormat:@"%@", [dic objectForKey:@"data"]];
        globalManager.isLogined = YES;
        
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:globalManager.token forKey:@"token"];
        [defaults synchronize];
        
        NSNotification *notice = [NSNotification notificationWithName:NotificationLoginSccess object:nil];
        [[NSNotificationCenter defaultCenter] postNotification:notice];
        [self.navigationController popToRootViewControllerAnimated:true];
    } else {
        
        UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"温馨提示！" message:[NSString stringWithFormat:@"%@", [dic objectForKey:@"message"]] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alerView show];
    }
}
 */
-(void)next:(UIButton *)btn
{
    btn.enabled = NO;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        btn.enabled = YES;
    });
    if ([GlobalUnit isBlankString:phone.text]) {
        [GlobalUnit showPopHint:@"请输入手机号" targetView:phone showInView:self.view];
        return;
    }
    if ([GlobalUnit isBlankString:code.text]) {
        [GlobalUnit showPopHint:@"请输入验证码" targetView:code showInView:self.view];
        return;
    }
    if ([GlobalUnit isBlankString:passward.text]) {
        [GlobalUnit showPopHint:@"请输入密码" targetView:passward showInView:self.view];
        return;
    }
    if ([GlobalUnit isBlankString:passwardConfirm.text]) {
        [GlobalUnit showPopHint:@"请重新输入密码" targetView:passwardConfirm showInView:self.view];
        return;
    }
    if (![passward.text isEqualToString:passwardConfirm.text]) {
        
        [GlobalUnit showPopHint:@"两次输入的密码不一样" targetView:passwardConfirm showInView:self.view];
        return;
    }
    if (!checkagreeBox.checked) {
        
        [GlobalUnit showAlertHint:@"温馨提示" message:@"您须同意用户使用协议之后才可以完成注册！"];
        return;
    }

    [NSThread detachNewThreadSelector:@selector(callServerRegister) toTarget:self withObject:Nil];
    [SVProgressHUD showWithStatus:@"加载中"];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setForegroundColor:EastMarket_MainToneColor];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
}

- (void)callServerRegister {
    
    NSDictionary *dic = [AppServiceInterface Register:phone.text password:passward.text verifyCode:code.text invitationCode:invitationCode.text];
    [self performSelectorOnMainThread:@selector(updateRegisterUI:) withObject:dic waitUntilDone:NO];
}

- (void)updateRegisterUI:(NSDictionary *)dic {
    
    [SVProgressHUD dismiss];
    debugLog(@"%@", [dic objectForKey:@"success"]);
    if ([[dic objectForKey:@"success"] integerValue] == 1) {
        
        [SVProgressHUD showWithStatus:[NSString stringWithFormat:@"%@", [dic objectForKey:@"msg"]]];
        NSNotification *notice = [NSNotification notificationWithName:NotificationLoginSccess object:nil];
        [[NSNotificationCenter defaultCenter] postNotification:notice];
        [self.navigationController popToRootViewControllerAnimated:true];
    } else if (dic && [[dic objectForKey:@"success"] integerValue] == 0) {
    
        [GlobalUnit showAlertHint:@"温馨提示！" message:[NSString stringWithFormat:@"%@", [dic objectForKey:@"msg"]]];
    }
    else {
        [GlobalUnit showAlertHint:@"温馨提示！" message:@"请求服务器失败，请稍后重试"];
    }
}

#pragma mark -- UITextViewDelegate
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    CGRect textFieldFrame      = textField.frame;
    //当前输入框的Y
    CGFloat textField_Y        = textFieldFrame.origin.y;
    //当前输入框的高度
    CGFloat textFieldHight     = textFieldFrame.size.height;
    //屏幕高度
    CGFloat screenHight        = self.view.frame.size.height;
    //键盘高度
    //    CGFloat keyBordHight       = keyBordHight;
    //键盘tabbar高度
    CGFloat keyBordTabbarHight = 49;
    //计算输入框向上移动的偏移量
    int offset = textField_Y + textFieldHight + 64 - (screenHight - KeyboardHeight - keyBordTabbarHight);
    
    //根据键盘遮挡的高度开始移动动画
    [UIView animateWithDuration:0.3 animations:^{
        if (offset > 0) {
            
            float width = self.view.frame.size.width;
            float hight = self.view.frame.size.height;
            
            CGRect rect = CGRectMake(0, -offset, width, hight);
            self.view.frame = rect;
        }
    }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
    //键盘收回后视图移动回原位的动画
    [UIView animateWithDuration:0.3 animations:^{
        
        float width = self.view.frame.size.width;
        float hight = self.view.frame.size.height;
        
        CGRect rect = CGRectMake(0, 44 + 20, width, hight);
        self.view.frame = rect;
    }];
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.view endEditing:YES];
    //点击Return,键盘收回后视图移动回原位的动画
    [UIView animateWithDuration:0.3 animations:^{
        
        float width = self.view.frame.size.width;
        float hight = self.view.frame.size.height;
        
        CGRect rect = CGRectMake(0, 44 + 20, width, hight);
        self.view.frame = rect;
    }];
    return YES;
}


#pragma mark -- QCheckBoxDelegate
- (void)didSelectedCheckBox:(QCheckBox *)checkbox checked:(BOOL)checked {
    
    if (checked) {
        debugLog(@"选中啦");
    }
}

- (void)taplblAgreement:(UIGestureRecognizer *)tap {
    
    debugMethod();
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
